/*
 * ContactableTreeCellRenderer.java
 *
 * Created on 28 February 2004, 10:18
 * Copyright (C) 2004, Velocityme Partnership
 */

package com.velocityme.client.gui.node.contactable;

import com.velocityme.valueobjects.ContactableValue;
import com.velocityme.valueobjects.NodeValue;
import javax.swing.JLabel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeCellRenderer;

/**
 *
 * @author  Robert Crida Work
 */
public class ContactableTreeCellRenderer extends JLabel implements TreeCellRenderer {
    
    /** Creates a new instance of ContactableTreeCellRenderer */
    public ContactableTreeCellRenderer() {
    }
    
    public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        if (value instanceof DefaultMutableTreeNode) {
            Object uo = ((DefaultMutableTreeNode)value).getUserObject();
            if (uo instanceof ContactableValue) {
                ContactableValue contactableValue = (ContactableValue)uo;
                setText(contactableValue.getNodeValue().getName());
            }
            else
                setText(uo.getClass().getName());
        }
        else
            setText(value.getClass().getName());
        setOpaque(selected);
        return this;
    }
    
}
